﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HumanResorcesProj.DAL._HR_DSTableAdapters;
using HumanResorcesProj.DAL;
using System.Security.Cryptography;
using System.Text;



namespace HumanResorcesProj.BLL
{
    public class Login
    {
        private LoginTableAdapter log = null;
        public LoginTableAdapter adapter
        {
            get
            {
                if (log == null) log = new LoginTableAdapter();
                return log;
            }
        }

        public void InsertNewUserRegister(string UserName, string PassWord)
        {
            PassWord = HashPassword(PassWord);
            
            adapter.InsertNewUserRegister(UserName, PassWord);


        }

        public static string HashPassword(string UnHashedPassword)
        {
            return Convert.ToBase64String(new SHA256Managed().ComputeHash(Encoding.UTF8.GetBytes(UnHashedPassword)));
        }



        public DAL._HR_DS.LoginDataTable GetData()
        {
            return adapter.GetData();
        }

        public DAL._HR_DS.LoginDataTable GetDataByLogName(string UserName)
        {
            return adapter.GetDataByLogName(UserName);
        }
       
    }
}
